/**
 * Created by yineng on 2017-3-20.
 */
openerp.xiaoyun_form_attachments = function (instance) {
    var _t = instance.web._t,
        _lt = instance.web._lt;
    var QWeb = instance.web.qweb;

    instance.web.FormView.include({
        load_form: function (data) {
            var self = this;
            this.$sidebar = this.options.$sidebar || this.$el.find('.oe_form_sidebar');
            if (!this.sidebar && this.options.$sidebar) {
                this.sidebar = new instance.web.Sidebar(this);
                if (!self.is_action_enabled('no_attach')) {
                    this.sidebar.sections.splice(1, 0, { 'name': 'files', 'label': _t('附件'), });
                    this.sidebar.items['files'] = [];
                }
                this.sidebar.appendTo(this.$sidebar);
                this.sidebar.uploading_access = self.is_action_enabled('edit');
                if (this.fields_view.toolbar) {
                    this.sidebar.add_toolbar(this.fields_view.toolbar);
                }
                this.sidebar.add_items('other', _.compact([
                        self.is_action_enabled('delete') && { label: _t('Delete'), callback: self.on_button_delete },
                        self.is_action_enabled('duplicate') && { label: _t('Duplicate'), callback: self.on_button_duplicate }
                ]));
            }
            self._super(data);
        }
    });
}